package com.everflourish.yeah100.act.base;

import android.content.Context;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.KeyEvent;

import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;
import com.everflourish.yeah100.utils.IntentUtil;
import com.everflourish.yeah100.utils.SystemApp;

/**
 * 基础的activity
 *
 * @author pf
 * @date 2015-1-8
 */
public class BaseActivity extends AppCompatActivity {

    public Context mContext;
    public SystemApp mSystemApp;
    public RequestQueue mQueue;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // requestWindowFeature(Window.FEATURE_NO_TITLE);
        mSystemApp = SystemApp.getInstance();
        mSystemApp.addStack(this);
        mContext = this;
        mQueue = Volley.newRequestQueue(mContext);
    }

    @Override
    public boolean onKeyUp(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            IntentUtil.finishActivity(this);
            return true;
        } else {
            return super.onKeyUp(keyCode, event);
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mQueue != null) {
            mQueue.stop();
        }
        mSystemApp.delActivity(this);
    }
}